home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Equivalents / ascii-engine.izs < prev    next >
Text File  |  2005-09-27  |  5KB  |  203 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>ASCII Engine 
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>This is an ascii tool, it gives you three outputs!<!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>Equivalents<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13. <!-- HOW TO INSTALL ASCII ENGINE:
  14.  
  15.   1.  Copy code into the HEAD section of document
  16.   2.  Put last coding into the BODY section of document  -->
  17.  
  18. <!-- STEP ONE: Add code into HEAD section of document  -->
  19.  
  20. <HEAD>
  21.  
  22. <SCRIPT LANGUAGE="JavaScript">
  23. <!-- Original:  Christopher Nielsen (chris@bluegalaxy.net) -->
  24. <!-- Web Site:  http://www.bluegalaxy.net -->
  25.  
  26.  
  27. <!-- Begin
  28. binary_numbers = new Array("0000", "0001", "0010", "0011", "0100", "0101", 
  29. "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111");
  30.  
  31. function toBinary(High, Low) {
  32. var hiHex = "ABCDEF";
  33. if (Low < 10 ) {
  34. LowNib = Low;
  35. }
  36. else {
  37. LowNib = 10 + hiHex.indexOf(Low); 
  38. }
  39. if (High  < 10 ) {
  40. HighNib = High;
  41. }
  42. else {
  43. HighNib = 10 + hiHex.indexOf(High);
  44. }
  45. eight_bits = binary_numbers[HighNib] + " " + binary_numbers[LowNib];
  46. return eight_bits;
  47. }
  48. function Dec2Hex(Decimal) {
  49. var hexChars = "0123456789ABCDEF";
  50. var a = Decimal % 16;
  51. var b = (Decimal - a)/16;
  52. hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
  53. L = hexChars.charAt(a);
  54. H = hexChars.charAt(b);
  55. return hex;
  56. }
  57. var symbols = " !\"#$%&'()*+'-./0123456789:;<=>?@";
  58. function toAscii ()  {
  59. var loAZ = "abcdefghijklmnopqrstuvwxyz";
  60. symbols+= loAZ.toUpperCase();
  61. symbols+= "[\\]^_`";
  62. symbols+= loAZ;
  63. symbols+= "{|}~";
  64. var loc;
  65. loc = symbols.indexOf(document.asciiform.Input.value);
  66. if (loc >-1) { 
  67. Ascii_Decimal = 32 + loc;
  68. return (32 + loc);
  69.    }
  70. return(0);  // If not in range 32-126 return ZERO
  71. }
  72. function getAscii(some_value) {
  73. document.asciiform.toDec.value = toAscii();
  74. document.asciiform.toHex.value = Dec2Hex(toAscii()); 
  75. document.asciiform.binary.value = toBinary(H, L); 
  76. }
  77. //  End -->
  78. </script>
  79. </HEAD>
  80.  
  81. <!-- STEP TWO: Add code into BODY section of document  -->
  82.  
  83. <BODY>
  84.  
  85. <center>
  86. <form name="asciiform" onsubmit="return false;">
  87. <table border=1><tr><td>
  88. <center>
  89. Input one character:  <input size=1 name=Input maxlength=1 onChange="getAscii(this.value)">
  90. <p>
  91. <input type=button  value="display" onClick="document.asciiform.toDec.value=toAscii()">
  92. </center>
  93. <p>
  94. <input size=10 name=toDec onFocus="this.blur()"> ASCII Decimal Output<br>
  95. <input size=10 name=toHex onFocus="this.blur()"> ASCII Hex Output<br>
  96. <input size=10 name=binary onFocus="this.blur()"> ASCII Binary Output
  97. </td>
  98. </tr>
  99. </table>
  100. </form>
  101. </center>
  102. <!-- END OF SCRIPT -->
  103. <!/SCRIPT>
  104.  
  105. <!PREVIEW>
  106. <!-- START OF SCRIPT -->
  107.  
  108.  
  109. <!-- HOW TO INSTALL ASCII ENGINE:
  110.  
  111.   1.  Copy code into the HEAD section of document
  112.   2.  Put last coding into the BODY section of document  -->
  113.  
  114. <!-- STEP ONE: Add code into HEAD section of document  -->
  115.  
  116. <HEAD>
  117.  
  118. <SCRIPT LANGUAGE="JavaScript">
  119. <!-- Original:  Christopher Nielsen (chris@bluegalaxy.net) -->
  120. <!-- Web Site:  http://www.bluegalaxy.net -->
  121.  
  122.  
  123. <!-- Begin
  124. binary_numbers = new Array("0000", "0001", "0010", "0011", "0100", "0101", 
  125. "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111");
  126.  
  127. function toBinary(High, Low) {
  128. var hiHex = "ABCDEF";
  129. if (Low < 10 ) {
  130. LowNib = Low;
  131. }
  132. else {
  133. LowNib = 10 + hiHex.indexOf(Low); 
  134. }
  135. if (High  < 10 ) {
  136. HighNib = High;
  137. }
  138. else {
  139. HighNib = 10 + hiHex.indexOf(High);
  140. }
  141. eight_bits = binary_numbers[HighNib] + " " + binary_numbers[LowNib];
  142. return eight_bits;
  143. }
  144. function Dec2Hex(Decimal) {
  145. var hexChars = "0123456789ABCDEF";
  146. var a = Decimal % 16;
  147. var b = (Decimal - a)/16;
  148. hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
  149. L = hexChars.charAt(a);
  150. H = hexChars.charAt(b);
  151. return hex;
  152. }
  153. var symbols = " !\"#$%&'()*+'-./0123456789:;<=>?@";
  154. function toAscii ()  {
  155. var loAZ = "abcdefghijklmnopqrstuvwxyz";
  156. symbols+= loAZ.toUpperCase();
  157. symbols+= "[\\]^_`";
  158. symbols+= loAZ;
  159. symbols+= "{|}~";
  160. var loc;
  161. loc = symbols.indexOf(document.asciiform.Input.value);
  162. if (loc >-1) { 
  163. Ascii_Decimal = 32 + loc;
  164. return (32 + loc);
  165.    }
  166. return(0);  // If not in range 32-126 return ZERO
  167. }
  168. function getAscii(some_value) {
  169. document.asciiform.toDec.value = toAscii();
  170. document.asciiform.toHex.value = Dec2Hex(toAscii()); 
  171. document.asciiform.binary.value = toBinary(H, L); 
  172. }
  173. //  End -->
  174. </script>
  175. </HEAD>
  176.  
  177. <!-- STEP TWO: Add code into BODY section of document  -->
  178.  
  179. <BODY>
  180.  
  181. <center>
  182. <form name="asciiform" onsubmit="return false;">
  183. <table border=1><tr><td>
  184. <center>
  185. Input one character:  <input size=1 name=Input maxlength=1 onChange="getAscii(this.value)">
  186. <p>
  187. <input type=button  value="display" onClick="document.asciiform.toDec.value=toAscii()">
  188. </center>
  189. <p>
  190. <input size=10 name=toDec onFocus="this.blur()"> ASCII Decimal Output<br>
  191. <input size=10 name=toHex onFocus="this.blur()"> ASCII Hex Output<br>
  192. <input size=10 name=binary onFocus="this.blur()"> ASCII Binary Output
  193. </td>
  194. </tr>
  195. </table>
  196. </form>
  197. </center>
  198.  
  199. <!-- END OF SCRIPT -->
  200. <!/PREVIEW>
  201.  
  202. <!RELATED>NONE<!/RELATED>
  203.